package com.css.fghs.config;


import com.css.fghs.filter.SecurityFilter;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import javax.servlet.Filter;

@Configuration
public class FilterConfiguration implements WebMvcConfigurer {


    @Bean
    public FilterRegistrationBean<SecurityFilter> znsbSessionFilter() {
        return createFilterBean(new SecurityFilter(), -98);
    }

    public static <T extends Filter> FilterRegistrationBean<T> createFilterBean(T filter, Integer order) {
        FilterRegistrationBean<T> bean = new FilterRegistrationBean<>(filter);
        bean.setOrder(order);
        return bean;
    }

}
